package com.zzz.web.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class linkDB {
    static final String driverClassName = "com.mysql.cj.jdbc.Driver";
    static final String url = "jdbc:mysql://120.27.237.68:3306/indoor_localization?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";


    static final String username = "root";
    static final  String userpassword = "Zzz16543213@";

    static Connection conn = null;

    public Connection getConnection() {// 连接数据库
        try {
            Class.forName(driverClassName);
            conn = DriverManager.getConnection(url, username, userpassword);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public void closeConnection() { // 关闭数据库的连接
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

    }
}
